<?php include_once "top.php";
if($_GET['del']){
	$db->ig2_delete('mae_prize','id='.$_GET['del']);
	tellgoto('删除成功','products.php');
}
?>
<div class="addleft">
	<a href="products.php">商品列表</a>
	<a href="product_edit.php">添加商品</a>
	<a href="ex_record.php">兑换记录(卡券)</a>
	<a href="ex_record2.php">兑换记录(实物)</a>
</div>
<div class="addbar">
	<ul>
	<h2>商品列表</h2>
	
	<li class="lihd"><strong align="center">
		<label>商品ID</label>
		<label style="width:150px">商品名称</label>
		<label>所需积分</label>
		<label>商品类型</label>
		<label>商品库存</label>
		<label>商品状态</label>
		<label style="width:150px">封面图片</label>
		<label style="width:150px">操作</label>
		</strong>
	</li>
	
	<?php foreach($db->ig2_select('mae_prize','1 order by id desc') as $list){?>
	<li align="center">
		<label><?php echo $list['id']?></label>
		<label style="width:150px"><?php echo $list['name']?></label>
		<label><?php echo $list['need_integral']?></label>
		<label><?php switch($list['is_virtual']){
			case 0 : echo '实物商品'; break;
			case 1 : echo '虚拟商品'; break;
		}?></label>
		<label><?php 
		if($list['is_virtual']==0){
			echo $list['stock'];
		}else{
			$stock=count($db->ig2_select('mae_prize_virtual','prize_id='.$list['id'].' and is_used=0'));
			echo $stock;
		}
		?></label>
		<label><?php switch($list['status']){
			case 0 : echo '上架'; break;
			case 1 : echo '下架'; break;
		}?></label>
		<label style="width:150px"><img src="../prize/<?php echo $list['img']?>" style="width:60px"></label>
		<label style="width:150px">
			<a href="product_edit.php?id=<?php echo $list['id']?>">修改</a> |
			<a href="javascript:void(0)" onclick="if(confirm('该操作不可恢复，请确认是否删除')) window.location.href='products.php?del=<?php echo $list['id']?>'">删除</a>
		</label>
	</li>
	<?php }?>
	
	</ul>
</div>
<?php include_once "down.php";?>